import React, { Component } from 'react'

export default class App extends Component {

  constructor(props) {
    super(props)
    this.state = {
      fruit: "banana"
    }
  }

  render() {
    return (
      <div>
        <form onSubmit={e => { this.handleSubmit(e) }}>
          <select name="fruits" 
                  onChange={e => this.handleChange(e)}
                  value={this.state.fruit}>
            <option value="apple">苹果</option>
            <option value="banana">香蕉</option>
            <option value="orange">橙子</option>
          </select>
          <input type="submit" value="提交"/>
        </form>
      </div>
    )
  }
  handleSubmit(event) {
    event.preventDefault()

    console.log(this.state.fruit)

  }

  handleChange(event) {
    this.setState({
      fruit: event.target.value
    })
  }
}
